package com.kila.entity;

import com.kila.CourseFactory.CourseFactory;
import com.kila.newinstance.HtmlCourse;
import com.kila.newinstance.ICourse;
import com.kila.newinstance.JavaCourse;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Student {
    private int stuNo;
    private String stuName;
    private String stuAge;


    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public String getStuAge() {
        return stuAge;
    }

    public void setStuAge(String stuAge) {
        this.stuAge = stuAge;
    }

    public int getStuNo() {
        return stuNo;
    }

    public void setStuNo(int stuNo) {
        this.stuNo = stuNo;
    }

    //学习课程

    public void learnJava(){
        ICourse course = new JavaCourse();
        course.learn();
    }


    public void learnHtml(){
         ICourse course = new HtmlCourse();
         course.learn();
    }


    //学习任意课程
    public void learn(String name){
//        ICourse course = CourseFactory.getCourse(name);
//
//        course.learn();

        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
        ICourse course =(ICourse)applicationContext.getBean(name);
        course.learn();

    }


}
